<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
    <el-form-item label="设备号" prop="ssObj">
      <el-input v-model="dataForm.ssObj" placeholder="设备号"></el-input>
    </el-form-item>
    <el-form-item label="光伏板输入电压(V)" prop="ssUdfchar01">
      <el-input v-model="dataForm.ssUdfchar01" placeholder="光伏板输入电压(V)"></el-input>
    </el-form-item>
    <el-form-item label="光伏板输入电流(A)" prop="ssUdfchar02">
      <el-input v-model="dataForm.ssUdfchar02" placeholder="光伏板输入电流(A)"></el-input>
    </el-form-item>
    <el-form-item label="光伏板输入功率(W)" prop="ssUdfchar03">
      <el-input v-model="dataForm.ssUdfchar03" placeholder="光伏板输入功率(W)"></el-input>
    </el-form-item>
    <el-form-item label="光感输入电压(V)" prop="ssUdfchar04">
      <el-input v-model="dataForm.ssUdfchar04" placeholder="光感输入电压(V)"></el-input>
    </el-form-item>
    <el-form-item label="LED驱动器输出电压（V)" prop="ssUdfchar05">
      <el-input v-model="dataForm.ssUdfchar05" placeholder="LED驱动器输出电压（V)"></el-input>
    </el-form-item>
    <el-form-item label="LED驱动器输出电流（A)" prop="ssUdfchar06">
      <el-input v-model="dataForm.ssUdfchar06" placeholder="LED驱动器输出电流（A)"></el-input>
    </el-form-item>
    <el-form-item label="LED驱动器输出功率（W)" prop="ssUdfchar07">
      <el-input v-model="dataForm.ssUdfchar07" placeholder="LED驱动器输出功率（W)"></el-input>
    </el-form-item>
    <el-form-item label="LED驱动器输出状态" prop="ssUdfchar08">
      <el-input v-model="dataForm.ssUdfchar08" placeholder="LED驱动器输出状态"></el-input>
    </el-form-item>
    <el-form-item label="LED驱动器已输出时间（H)" prop="ssUdfchar09">
      <el-input v-model="dataForm.ssUdfchar09" placeholder="LED驱动器已输出时间（H)"></el-input>
    </el-form-item>
    <el-form-item label="蓄电池电压（V)" prop="ssUdfchar10">
      <el-input v-model="dataForm.ssUdfchar10" placeholder="蓄电池电压（V)"></el-input>
    </el-form-item>
    <el-form-item label="蓄电池充电电流（A)" prop="ssUdfchar11">
      <el-input v-model="dataForm.ssUdfchar11" placeholder="蓄电池充电电流（A)"></el-input>
    </el-form-item>
    <el-form-item label="蓄电池充电功率（W)" prop="ssUdfchar12">
      <el-input v-model="dataForm.ssUdfchar12" placeholder="蓄电池充电功率（W)"></el-input>
    </el-form-item>
    <el-form-item label="蓄电池总充电量（度）" prop="ssUdfchar13">
      <el-input v-model="dataForm.ssUdfchar13" placeholder="蓄电池总充电量（度）"></el-input>
    </el-form-item>
    <el-form-item label="蓄电池剩余电量比" prop="ssUdfchar14">
      <el-input v-model="dataForm.ssUdfchar14" placeholder="蓄电池剩余电量比"></el-input>
    </el-form-item>
    <el-form-item label="蓄电池当前状态" prop="ssUdfchar15">
      <el-input v-model="dataForm.ssUdfchar15" placeholder="蓄电池当前状态"></el-input>
    </el-form-item>
    <el-form-item label="风机输入直流电压(V)" prop="ssUdfchar16">
      <el-input v-model="dataForm.ssUdfchar16" placeholder="风机输入直流电压(V)"></el-input>
    </el-form-item>
    <el-form-item label="风机输入直流电流(A)" prop="ssUdfchar17">
      <el-input v-model="dataForm.ssUdfchar17" placeholder="风机输入直流电流(A)"></el-input>
    </el-form-item>
    <el-form-item label="风机热效电流(W)" prop="ssUdfchar18">
      <el-input v-model="dataForm.ssUdfchar18" placeholder="风机热效电流(W)"></el-input>
    </el-form-item>
    <el-form-item label="风机输入直流功率电压(V)" prop="ssUdfchar19">
      <el-input v-model="dataForm.ssUdfchar19" placeholder="风机输入直流功率电压(V)"></el-input>
    </el-form-item>
    <el-form-item label="风机有限充电电流（A)" prop="ssUdfchar20">
      <el-input v-model="dataForm.ssUdfchar20" placeholder="风机有限充电电流（A)"></el-input>
    </el-form-item>
    <el-form-item label="风机卸荷平均电流（A)" prop="ssUdfchar21">
      <el-input v-model="dataForm.ssUdfchar21" placeholder="风机卸荷平均电流（A)"></el-input>
    </el-form-item>
    <el-form-item label="风机当前转速（Rpm）" prop="ssUdfchar22">
      <el-input v-model="dataForm.ssUdfchar22" placeholder="风机当前转速（Rpm）"></el-input>
    </el-form-item>
    <el-form-item label="风机运行状态" prop="ssUdfchar23">
      <el-input v-model="dataForm.ssUdfchar23" placeholder="风机运行状态"></el-input>
    </el-form-item>
    <el-form-item label="第一路输出电流（A)" prop="ssUdfchar24">
      <el-input v-model="dataForm.ssUdfchar24" placeholder="第一路输出电流（A)"></el-input>
    </el-form-item>
    <el-form-item label="第一路输出功率（W)" prop="ssUdfchar25">
      <el-input v-model="dataForm.ssUdfchar25" placeholder="第一路输出功率（W)"></el-input>
    </el-form-item>
    <el-form-item label="第一路输出状态" prop="ssUdfchar26">
      <el-input v-model="dataForm.ssUdfchar26" placeholder="第一路输出状态"></el-input>
    </el-form-item>
    <el-form-item label="第一路控制模式" prop="ssUdfchar27">
      <el-input v-model="dataForm.ssUdfchar27" placeholder="第一路控制模式"></el-input>
    </el-form-item>
    <el-form-item label="控制部分" prop="ssUdfchar28">
      <el-input v-model="dataForm.ssUdfchar28" placeholder="控制部分"></el-input>
    </el-form-item>
    <el-form-item label="控制箱温度(A)" prop="ssUdfchar29">
      <el-input v-model="dataForm.ssUdfchar29" placeholder="控制箱温度(A)"></el-input>
    </el-form-item>
    <el-form-item label="蓄电池电压（V)" prop="ssUdfchar30">
      <el-input v-model="dataForm.ssUdfchar30" placeholder="蓄电池电压（V)"></el-input>
    </el-form-item>
    <el-form-item label="监控部分" prop="ssUdfchar31">
      <el-input v-model="dataForm.ssUdfchar31" placeholder="监控部分"></el-input>
    </el-form-item>
    <el-form-item label="摄像头当前状态" prop="ssUdfchar32">
      <el-input v-model="dataForm.ssUdfchar32" placeholder="摄像头当前状态"></el-input>
    </el-form-item>
    <el-form-item label="摄像头连接状态" prop="ssUdfchar33">
      <el-input v-model="dataForm.ssUdfchar33" placeholder="摄像头连接状态"></el-input>
    </el-form-item>
    <el-form-item label="摄像头连接状态" prop="ssUdfchar34">
      <el-input v-model="dataForm.ssUdfchar34" placeholder="摄像头连接状态"></el-input>
    </el-form-item>
    <el-form-item label="摄像头输出电压（V)" prop="ssUdfchar35">
      <el-input v-model="dataForm.ssUdfchar35" placeholder="摄像头输出电压（V)"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          ssId: 0,
          ssObj: '',
          ssUdfchar01: '',
          ssUdfchar02: '',
          ssUdfchar03: '',
          ssUdfchar04: '',
          ssUdfchar05: '',
          ssUdfchar06: '',
          ssUdfchar07: '',
          ssUdfchar08: '',
          ssUdfchar09: '',
          ssUdfchar10: '',
          ssUdfchar11: '',
          ssUdfchar12: '',
          ssUdfchar13: '',
          ssUdfchar14: '',
          ssUdfchar15: '',
          ssUdfchar16: '',
          ssUdfchar17: '',
          ssUdfchar18: '',
          ssUdfchar19: '',
          ssUdfchar20: '',
          ssUdfchar21: '',
          ssUdfchar22: '',
          ssUdfchar23: '',
          ssUdfchar24: '',
          ssUdfchar25: '',
          ssUdfchar26: '',
          ssUdfchar27: '',
          ssUdfchar28: '',
          ssUdfchar29: '',
          ssUdfchar30: '',
          ssUdfchar31: '',
          ssUdfchar32: '',
          ssUdfchar33: '',
          ssUdfchar34: '',
          ssUdfchar35: ''
        },
        dataRule: {
          ssObj: [
            { required: true, message: '设备号不能为空', trigger: 'blur' }
          ],
          ssUdfchar01: [
            { required: true, message: '光伏板输入电压(V)不能为空', trigger: 'blur' }
          ],
          ssUdfchar02: [
            { required: true, message: '光伏板输入电流(A)不能为空', trigger: 'blur' }
          ],
          ssUdfchar03: [
            { required: true, message: '光伏板输入功率(W)不能为空', trigger: 'blur' }
          ],
          ssUdfchar04: [
            { required: true, message: '光感输入电压(V)不能为空', trigger: 'blur' }
          ],
          ssUdfchar05: [
            { required: true, message: 'LED驱动器输出电压（V)不能为空', trigger: 'blur' }
          ],
          ssUdfchar06: [
            { required: true, message: 'LED驱动器输出电流（A)不能为空', trigger: 'blur' }
          ],
          ssUdfchar07: [
            { required: true, message: 'LED驱动器输出功率（W)不能为空', trigger: 'blur' }
          ],
          ssUdfchar08: [
            { required: true, message: 'LED驱动器输出状态不能为空', trigger: 'blur' }
          ],
          ssUdfchar09: [
            { required: true, message: 'LED驱动器已输出时间（H)不能为空', trigger: 'blur' }
          ],
          ssUdfchar10: [
            { required: true, message: '蓄电池电压（V)不能为空', trigger: 'blur' }
          ],
          ssUdfchar11: [
            { required: true, message: '蓄电池充电电流（A)不能为空', trigger: 'blur' }
          ],
          ssUdfchar12: [
            { required: true, message: '蓄电池充电功率（W)不能为空', trigger: 'blur' }
          ],
          ssUdfchar13: [
            { required: true, message: '蓄电池总充电量（度）不能为空', trigger: 'blur' }
          ],
          ssUdfchar14: [
            { required: true, message: '蓄电池剩余电量比不能为空', trigger: 'blur' }
          ],
          ssUdfchar15: [
            { required: true, message: '蓄电池当前状态不能为空', trigger: 'blur' }
          ],
          ssUdfchar16: [
            { required: true, message: '风机输入直流电压(V)不能为空', trigger: 'blur' }
          ],
          ssUdfchar17: [
            { required: true, message: '风机输入直流电流(A)不能为空', trigger: 'blur' }
          ],
          ssUdfchar18: [
            { required: true, message: '风机热效电流(W)不能为空', trigger: 'blur' }
          ],
          ssUdfchar19: [
            { required: true, message: '风机输入直流功率电压(V)不能为空', trigger: 'blur' }
          ],
          ssUdfchar20: [
            { required: true, message: '风机有限充电电流（A)不能为空', trigger: 'blur' }
          ],
          ssUdfchar21: [
            { required: true, message: '风机卸荷平均电流（A)不能为空', trigger: 'blur' }
          ],
          ssUdfchar22: [
            { required: true, message: '风机当前转速（Rpm）不能为空', trigger: 'blur' }
          ],
          ssUdfchar23: [
            { required: true, message: '风机运行状态不能为空', trigger: 'blur' }
          ],
          ssUdfchar24: [
            { required: true, message: '第一路输出电流（A)不能为空', trigger: 'blur' }
          ],
          ssUdfchar25: [
            { required: true, message: '第一路输出功率（W)不能为空', trigger: 'blur' }
          ],
          ssUdfchar26: [
            { required: true, message: '第一路输出状态不能为空', trigger: 'blur' }
          ],
          ssUdfchar27: [
            { required: true, message: '第一路控制模式不能为空', trigger: 'blur' }
          ],
          ssUdfchar28: [
            { required: true, message: '控制部分不能为空', trigger: 'blur' }
          ],
          ssUdfchar29: [
            { required: true, message: '控制箱温度(A)不能为空', trigger: 'blur' }
          ],
          ssUdfchar30: [
            { required: true, message: '蓄电池电压（V)不能为空', trigger: 'blur' }
          ],
          ssUdfchar31: [
            { required: true, message: '监控部分不能为空', trigger: 'blur' }
          ],
          ssUdfchar32: [
            { required: true, message: '摄像头当前状态不能为空', trigger: 'blur' }
          ],
          ssUdfchar33: [
            { required: true, message: '摄像头连接状态不能为空', trigger: 'blur' }
          ],
          ssUdfchar34: [
            { required: true, message: '摄像头连接状态不能为空', trigger: 'blur' }
          ],
          ssUdfchar35: [
            { required: true, message: '摄像头输出电压（V)不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.ssId = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.ssId) {
            this.$http({
              url: this.$http.adornUrl(`/udp/r5rmskillstatus/info/${this.dataForm.ssId}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.ssObj = data.r5rmSkillstatus.ssObj
                this.dataForm.ssUdfchar01 = data.r5rmSkillstatus.ssUdfchar01
                this.dataForm.ssUdfchar02 = data.r5rmSkillstatus.ssUdfchar02
                this.dataForm.ssUdfchar03 = data.r5rmSkillstatus.ssUdfchar03
                this.dataForm.ssUdfchar04 = data.r5rmSkillstatus.ssUdfchar04
                this.dataForm.ssUdfchar05 = data.r5rmSkillstatus.ssUdfchar05
                this.dataForm.ssUdfchar06 = data.r5rmSkillstatus.ssUdfchar06
                this.dataForm.ssUdfchar07 = data.r5rmSkillstatus.ssUdfchar07
                this.dataForm.ssUdfchar08 = data.r5rmSkillstatus.ssUdfchar08
                this.dataForm.ssUdfchar09 = data.r5rmSkillstatus.ssUdfchar09
                this.dataForm.ssUdfchar10 = data.r5rmSkillstatus.ssUdfchar10
                this.dataForm.ssUdfchar11 = data.r5rmSkillstatus.ssUdfchar11
                this.dataForm.ssUdfchar12 = data.r5rmSkillstatus.ssUdfchar12
                this.dataForm.ssUdfchar13 = data.r5rmSkillstatus.ssUdfchar13
                this.dataForm.ssUdfchar14 = data.r5rmSkillstatus.ssUdfchar14
                this.dataForm.ssUdfchar15 = data.r5rmSkillstatus.ssUdfchar15
                this.dataForm.ssUdfchar16 = data.r5rmSkillstatus.ssUdfchar16
                this.dataForm.ssUdfchar17 = data.r5rmSkillstatus.ssUdfchar17
                this.dataForm.ssUdfchar18 = data.r5rmSkillstatus.ssUdfchar18
                this.dataForm.ssUdfchar19 = data.r5rmSkillstatus.ssUdfchar19
                this.dataForm.ssUdfchar20 = data.r5rmSkillstatus.ssUdfchar20
                this.dataForm.ssUdfchar21 = data.r5rmSkillstatus.ssUdfchar21
                this.dataForm.ssUdfchar22 = data.r5rmSkillstatus.ssUdfchar22
                this.dataForm.ssUdfchar23 = data.r5rmSkillstatus.ssUdfchar23
                this.dataForm.ssUdfchar24 = data.r5rmSkillstatus.ssUdfchar24
                this.dataForm.ssUdfchar25 = data.r5rmSkillstatus.ssUdfchar25
                this.dataForm.ssUdfchar26 = data.r5rmSkillstatus.ssUdfchar26
                this.dataForm.ssUdfchar27 = data.r5rmSkillstatus.ssUdfchar27
                this.dataForm.ssUdfchar28 = data.r5rmSkillstatus.ssUdfchar28
                this.dataForm.ssUdfchar29 = data.r5rmSkillstatus.ssUdfchar29
                this.dataForm.ssUdfchar30 = data.r5rmSkillstatus.ssUdfchar30
                this.dataForm.ssUdfchar31 = data.r5rmSkillstatus.ssUdfchar31
                this.dataForm.ssUdfchar32 = data.r5rmSkillstatus.ssUdfchar32
                this.dataForm.ssUdfchar33 = data.r5rmSkillstatus.ssUdfchar33
                this.dataForm.ssUdfchar34 = data.r5rmSkillstatus.ssUdfchar34
                this.dataForm.ssUdfchar35 = data.r5rmSkillstatus.ssUdfchar35
              }
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/udp/r5rmskillstatus/${!this.dataForm.ssId ? 'save' : 'update'}`),
              method: 'post',
              data: this.$http.adornData({
                'ssId': this.dataForm.ssId || undefined,
                'ssObj': this.dataForm.ssObj,
                'ssUdfchar01': this.dataForm.ssUdfchar01,
                'ssUdfchar02': this.dataForm.ssUdfchar02,
                'ssUdfchar03': this.dataForm.ssUdfchar03,
                'ssUdfchar04': this.dataForm.ssUdfchar04,
                'ssUdfchar05': this.dataForm.ssUdfchar05,
                'ssUdfchar06': this.dataForm.ssUdfchar06,
                'ssUdfchar07': this.dataForm.ssUdfchar07,
                'ssUdfchar08': this.dataForm.ssUdfchar08,
                'ssUdfchar09': this.dataForm.ssUdfchar09,
                'ssUdfchar10': this.dataForm.ssUdfchar10,
                'ssUdfchar11': this.dataForm.ssUdfchar11,
                'ssUdfchar12': this.dataForm.ssUdfchar12,
                'ssUdfchar13': this.dataForm.ssUdfchar13,
                'ssUdfchar14': this.dataForm.ssUdfchar14,
                'ssUdfchar15': this.dataForm.ssUdfchar15,
                'ssUdfchar16': this.dataForm.ssUdfchar16,
                'ssUdfchar17': this.dataForm.ssUdfchar17,
                'ssUdfchar18': this.dataForm.ssUdfchar18,
                'ssUdfchar19': this.dataForm.ssUdfchar19,
                'ssUdfchar20': this.dataForm.ssUdfchar20,
                'ssUdfchar21': this.dataForm.ssUdfchar21,
                'ssUdfchar22': this.dataForm.ssUdfchar22,
                'ssUdfchar23': this.dataForm.ssUdfchar23,
                'ssUdfchar24': this.dataForm.ssUdfchar24,
                'ssUdfchar25': this.dataForm.ssUdfchar25,
                'ssUdfchar26': this.dataForm.ssUdfchar26,
                'ssUdfchar27': this.dataForm.ssUdfchar27,
                'ssUdfchar28': this.dataForm.ssUdfchar28,
                'ssUdfchar29': this.dataForm.ssUdfchar29,
                'ssUdfchar30': this.dataForm.ssUdfchar30,
                'ssUdfchar31': this.dataForm.ssUdfchar31,
                'ssUdfchar32': this.dataForm.ssUdfchar32,
                'ssUdfchar33': this.dataForm.ssUdfchar33,
                'ssUdfchar34': this.dataForm.ssUdfchar34,
                'ssUdfchar35': this.dataForm.ssUdfchar35
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
